package com.sx.gongzhong.pest;


import android.content.Context;

import com.sx.gongzhong.model.HeadParamBean;
import com.sx.gongzhong.model.ReplyUserBean;
import com.sx.gongzhong.net.ApiManager;
import com.sx.gongzhong.net.BaseCallBack;
import com.sx.gongzhong.param.UpdateUserInfo;
import com.sx.gongzhong.utils.BaseUtil;
import com.sx.gongzhong.view.IVoidView;

import java.util.Map;

/**修改用户信息
 * Created by admin on 2018/1/9.
 */

public class UpdateUserInfoPest {
    private IVoidView iVoidView;

    public UpdateUserInfoPest(IVoidView iVoidView) {
        this.iVoidView = iVoidView;
    }
    //修改用户信息
    public void updateUserInfo(Context context, UpdateUserInfo userInfo) {
        Map<String,Object> map = HeadParamBean.getHead();
        map.put("name",userInfo.name);
        map.put("genderCode",userInfo.genderCode);
        if (!BaseUtil.isEmpty(userInfo.birthday)){
            map.put("birthday",userInfo.birthday);
        }
        if (!BaseUtil.isEmpty(userInfo.selfIntroduction)){
            map.put("selfIntroduction",userInfo.selfIntroduction);
        }
        if (!BaseUtil.isEmpty(userInfo.removeIds)){
            map.put("removeIds",userInfo.removeIds);
        }
        if (!BaseUtil.isEmpty(userInfo.headerId)){
            map.put("header.id",userInfo.headerId);
        }
        if (!BaseUtil.isEmpty(userInfo.mobilePhone)){
            map.put("mobilePhone",userInfo.mobilePhone);
        }
        new ApiManager().updateUserInfo(map,new BaseCallBack<ReplyUserBean.BaseResult<Void>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<Void> response) {
                iVoidView.voidView("");
            }
            @Override
            public void onFailures(String message) {
                iVoidView.showError(message);
            }
        });
    }
}
